<!-- 纸条管理 -->
<template>
    <div class="page-box h100 display-flex czbj">
        <p class="title-label mb10">字条管理</p>
        <dxtable :dataJson="dataJson" :portUrl="portUrl" :formJson="formJson" :qx="qx" ref="databale" :czFun="czFun" czWidth="220"></dxtable>
        <!-- :czFun="czFun" -->
    </div>
</template>
<script lang='ts' setup>
import { leixing } from "../../util/config";
import dxtable from "../../components/util/dxtable.vue";
import sort from "../../components/util/sort.vue";
import pupimg from "../../components/util/pupimg.vue";
import { dxget,dxpost } from "../../util/index";
import { NButton } from "naive-ui"
import { h, ref, reactive } from "vue";
import { NImage } from "naive-ui";
const databale = ref();
const initeer = () => {
    databale.value.initDataExpose();
};
let qxList = ref([]);
let dataJson = [
    {
        title: "账号类型",
        key: "accountType",
        width: 100,
        type: "select",
        options: [{
            label: "全部",
            value: ""
        }, {
            label: "微信",
            value: "0"
        }, {
            label: "QQ ",
            value: "1"
        }],
        search: true, // 是否在搜索栏展示
        render(row) {
            return row.accountType == 0 ? '微信' : "QQ"
        }
    },
    {
        title: "账号",
        width: 150,
        key: "accountNumber",
        search: true, // 是否在搜索栏展示
    },
    {
        title: "纸条内容",
        key: "content",
        ellipsis: {
            tooltip: true
        }
    },
    {
        title: "照片",
        key: "photo",
        width: 100,
        render(row) {
            let imglist = row.photo
            if (row.photo) {
                try {
                    imglist = row.photo.split(",")
                } catch (e) {

                }
                row.photo = imglist
                return h(pupimg, { imglist: imglist })
            }
            row.photo = []

        }
    },
    {
        title: '头像',
        key: 'headimgurl',
        width: 60,
        render(row) {
            if (row.headimgurl) {
                return h('img', { class: "dsfsdtrtr", src: row.headimgurl })
            } else {
                return '--'
            }

        }
    },
    {
        title: "昵称",
        width: 120,
        key: "nickname",
        search: true, // 是否在搜索栏展示
        render(row) {
            if (row.nickname) {
                return row.nickname
            } else {
                return '--'
            }
        }
    },
    {
        title: "类型",
        width: 100,
        render(row) {
            if(row.userType == 2 ||row.stripState==2){
                return '高质量纸条'
            }
            return "普通纸条"
        }
    },
    {
        title: "纸条性别",
        key: "StripType",
        width: 100,
        type: "select",
        options: [{
            label: "全部",
            value: ""
        }, {
            label: "男生",
            value: 1
        }, {
            label: "女生 ",
            value: 2
        }],
        search: true, // 是否在搜索栏展示
        render(row) {
            return row.StripType == 1 ? '男生' : "女生"
        }
    },
    {
        title: "省份",
        width: 100,
        key: "province",
        search: true, // 是否在搜索栏展示
        render(row) {
            return row.province || '--'
        },
    },
    // {
    //     title: "城市",
    //     width: 100,
    //     key: "city",
    //     search: true, // 是否在搜索栏展示
    //     render(row) {
    //         return row.city ||'--'
    //     },
    // },
    {
        title: "创建时间",
        key: "addTime",
        width: 150,
    },
];
const qx = {
    DeletePermissionID: "mhStripManagementdel", //删除
    EditPermissionIdentifier: "mhStripManagementbj", // 编辑
    NewPermissionIdentifier: "mhStripManagementxz", // 新建
    ViewPermissionID: "mhStripManagementck", // 查看
};
// const portUrl = "dxgjAdmin/administrator?CharacterNameCode=" + leixing;
const portUrl = "mh/mhStripManagement";
let formJson = reactive([
    {
        title: "账号类型",
        key: "accountType",
        type: "select",
        val: "0",

        options: [{
            label: "微信",
            value: "0"
        }, {
            label: "QQ ",
            value: "1"
        }]
    },
    {
        title: "账号",
        type: "input",
        required: true, // 是否为必填
        key: "accountNumber",
    },
    {
        title: "纸条内容",
        key: "content",
        type: "textarea",
    },
    {
        title: "照片",
        key: "photo",
        type: "imglist",

        val: []
    }, {
        title: "纸条类型",
        key: "StripType",
        type: "select",
        required: true, // 是否为必填
        val: 1,
        options: [{
            label: "男生",
            value: 1
        }, {
            label: "女生 ",
            value: 2
        }]
    }, {
        title: "省份",
        key: "province",
        type: "select",
        options: []
    }, {
        title: "审核状态",
        key: "audit",
        type: "select",
        options: [{
            label: "等待审核",
            value: 1
        }, {
            label: "审核通过 ",
            value: 2
        }, {
            label: "审核不通过 ",
            value: 3
        }]
    }, {
        title: "审核备注",
        key: "censorContent",
        type: "textarea",
    },
]);


const getarea = async () => {
    const { data }: any = await dxget("public/area")
    data.map(a=>{
        a.value=a.label
    })
    data.unshift({
        label:"不限",
        value:"不限"
    })
    formJson[5].options = data
}
getarea()
const czFun = {
    fun: (row) => {
        const stripState = row.stripState
        const userType = row.userType
        return [
            h(
                NButton,
                {
                    type: "info",
                    quaternary: true,
                    onClick: async (e) => {
                        let jjnhe = 2
                        if (stripState == 2) {
                            jjnhe = 1
                        }
                        await dxpost(portUrl, { id: row.id, stripState: jjnhe }, 'put')
                        row.stripState = jjnhe
                    },
                },
                stripState == '2' ? '设为普通' : "设为高质量"
            ),
        ];
    },
};
</script>
<style scoped></style>